package com.oron3.bouncer.objects.shapes;

import java.util.Random;

/**
 * 
 */

/**
 * @author Ofek
 *
 */
public class TestProjection {

	public static void main(final String[] args) {

		final Rectangle zx1 = new Rectangle(new Point(0, 0, 100), new Point(0, 0, 0), new Point(100, 0, 0));
		final Rectangle xy1 = new Rectangle(new Point(100, 0, 0), new Point(0, 0, 0), new Point(0, 100, 0));
		final Rectangle yz1 = new Rectangle(new Point(0, 100, 0), new Point(0, 0, 0), new Point(0, 0, 100));
		//		System.out.println(yz1.intersection(new Line(new Point(1,7,90),new Point(0,7,90))));
		//		checkInside(new Rectangle(new Point(100,0,0),new Point(100,100,0),new Point(100,100,100)));
		//		checkInside(new Rectangle(new Point(100,100,100),new Point(100,100,0),new Point(0,100,0)));
		//		checkInside(new Rectangle(new Point(0,100,100),new Point(0,0,100),new Point(100,0,100)));
		//		checkInside(zx1);
		//		checkInside(xy1);
		//		checkInside(yz1);
		final Point point = new Point(-69.428635f, 88.96324f, 166.55669f);
		final Arc worldArc = new Arc(Point.ZERO, 100, 100, 100);
		final Point closestPoint = worldArc.closestPoint(point);
		//		System.out.println(closestPoint);
		for (float a = 0; a <= Math.PI; a += Math.PI / 100) {
			for (float b = 0; b <= Math.PI; b += Math.PI / 100) {
				Point pPoint = new PPoint(60, b, a).toCartesian();
				pPoint=pPoint.add(50,50,50);
				System.out.println(pPoint);
				final Line line = new Line(worldArc.center, pPoint);
				System.out.println(worldArc.isInside(pPoint));
			}
		}
	}

	/**
	 * @param zx1
	 */
	private static void checkInside(final Rectangle r) {
		System.out.println("Checking " + r);
		for (int i = 0; i < 8; i++) {
			testRandomPoint(r);
		}
	}

	/**
	 * @param r
	 */
	private static void testRandomPoint(final Rectangle r) {
		final Random random = new Random();
		final Point p = new Point(-69.428635f, 88.96324f, 166.55669f);//new Point(random.nextFloat()*(-220)+110,random.nextFloat()*(-220)+110,random.nextFloat()*(-220)+110);
		System.out.println(String.format("Point(%.2f,%.2f,%.2f) %s", p.x, p.y, p.z, r.isInside(p) ? "is inside" : "is outside"));
	}

}
